﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kaskelot.SP.Core
{
	public static class GuidExtensions
	{
		public static bool IsGuid(this string guid)
		{
			bool result = false;

			if (guid.IsNonEmpty())
			{
				try
				{
					new Guid(guid);
					result = true;
				}
				catch (FormatException) { }
			}

			return result;
		}

		public static Guid? TryParseGuid(this string guid)
		{
			Guid? result = null;

			try
			{
				result = new Guid(guid);
			}
			catch (FormatException) { }

			return result;
		}
	}
}
